﻿using System;
using System.IO;
using System.Windows.Forms;

namespace SubFps
{
    public static class Helper
    {
        public static string TryGetDirectoryName(string filePath)
        {
            try
            {
                return Path.GetDirectoryName(filePath);
            }
            catch { return string.Empty; }
        }
        public static bool TryInvoke(Action action)
        {
            try
            {
                action();
                return true;
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
                return false;
            }
        }
        public static void ShowError(string message, string caption = "Error")
        {
            MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        public static void ShowInfo(string message, string caption = "Information")
        {
            MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
}
